<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .tab ul {
      list-style: none;
    }

    .tab .btns {
      display: block;
      height: 60px;
      width: 808px;
      margin: 0 auto;
    }

    .tab .btns li {
      float: left;
      width: 200px;
      height: 60px;
      line-height: 60px;
      text-align: center;
      border: solid 1px red;
      cursor: default;
    }

    .tab .contents {
      clear: both;
    }

    .tab .contents li {
      height: 400px;
      line-height: 400px;
      text-align: center;
      background-color: #00c1de;
      display: none;
      cursor: default;
    }

    .tab .btns li.active {
      color: #00c1de;
    }

    .tab .contents li.active {
      display: block;
    }
  </style>
</head>

<body>
  <div class="tab">
    <ul class="btns">
      <li class="active">tab1</li>
      <li>tab2</li>
      <li>tab3</li>
      <li>tab4</li>
    </ul>
    <ul class="contents">
      <li class="active">content1</li>
      <li>content2</li>
      <li>content3</li>
      <li>content4</li>
    </ul>
  </div>
  <script src="./libs/jquery-1.12.4.js"></script>
  <script>
    $(function () {
      $('.btns').on('click', 'li', function () {
        /* 点击元素.添加类名(active).所有同胞(有active类名的).删除类名(active) */
        $(this).addClass('active').siblings('.active').removeClass('active')
        /* li.第对应下标的那个组成jquery对象.添加类名(active).所有同胞(有active类名的).删除类名(active) */
        $('.contents li').eq($(this).index()).addClass('active').siblings('.active').removeClass('active')
      })

    })


  </script>
</body>

</html>